package com.thenie.service.impl;

import com.thenie.mapper.RoomMapper;
import com.thenie.pojo.Room;
import com.thenie.service.RoomService;
import com.thenie.vo.RoomVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class RoomServiceImpl implements RoomService {
    @Resource
    private RoomMapper roomMapper;
    /**
     * 查询房间列表
     * @param roomVo
     * @return
     */
    public List<Room> findRoomList(RoomVo roomVo) {
        return roomMapper.findRoomList(roomVo);
    }

    /**
     * 插入一条房间数据
     * @param room
     * @return
     */
    public int addRoom(Room room){
        return roomMapper.insertRoom(room);
    }

    /**
     * 修改房间数据
     * @param room
     * @return
     */
    public int updateRoom(Room room){
        return roomMapper.updateRoom(room);
    }

    /**
     * 删除一个房间
     * @param id
     * @return
     */
    public int deleteRoom(int id){
        return roomMapper.deleteRoom(id);
    }

    /**
     * 根据楼层id查询房间集合
     * @param floorId
     * @return
     */
    public List<Room> findRoomByFloorId(int floorId){
        return roomMapper.findRoomByFloorId(floorId);
    }

    public Room roomInfo(Integer roomId) {
        Room room = roomMapper.roomInfo(roomId);
        return room;
    }
}
